package com.jcw.kqxt.service.impl;

import com.jcw.kqxt.domain.Attendance;
import com.jcw.kqxt.mapper.AttendanceMapper;
import com.jcw.kqxt.result.JSONResult;
import com.jcw.kqxt.service.IExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Service
public class ExcelServiceImpl implements IExcelService {
    @Autowired
    private AttendanceMapper attendanceMapper;
    /**
     * 导出
     */
    @Override
    public JSONResult export(HttpServletResponse response,String month) {
//        AttendanceFindAllDto findAllDto = new AttendanceFindAllDto();
//        List<Attendance> list = attendanceMapper.selectListByDto(findAllDto);
//        List<Attendance> result = new ArrayList<>();
//        list.stream().forEach(area -> {
//            Attendance attendance = new Attendance();
//            try {
//                BeanUtils.copyProperties(area, attendance);
//            } catch (IllegalAccessException e) {
//                e.printStackTrace();
//            } catch (InvocationTargetException e) {
//                e.printStackTrace();
//            }
//            result.add(attendance);
//        });
//        IntStream.range(0, result.size()).forEach(i -> {
//            result.get(i).setId((long) (i + 1));
//        });
//        try {
//            Map<String, Object> param = new HashMap<>();
//            param.put("title", "考情表");
//            param.put("list", result);
//            TemplateExcelUtils.downLoadExcel("省份数据", "province.xls", param, response);
//        } catch (Exception e) {
//            throw new RuntimeException("错了");
//        }
//        return JSONResult.success("导出成功");

        List<Attendance> list = attendanceMapper.selectList(null);
        return null;
   }
}